import format from '@dfeidao/atom-web/dt/format';
import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set from '@dfeidao/atom-web/local/set';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p001 from './p001';
import p002 from './p002';
import p003 from './p003';
import p004 from './p004';
import p006 from './p006';
import p007 from './p007';
// import s from 'src/basic-data-wzz/s';

export default async function a001(fd: IFeidaoAiBrowserComponent, no: string) {
	// todo
	set(fd, 'no', no);
	const n = fd.data.node.querySelector('[data-id="detail"]');
	n.setAttribute('class', '');
	const res = await nodejs<{ data: Array<{ equip_no: string, equip_type_name: string, equip_type_no: string, equip_internal_no: string, equip_name: string, transfer_time: string, fixed_assets_type: string, transfer_price: string, manufacturer: string, manu_years: string, transfer_date: number }> }>('device-management-ygh/zj-000010/s001', {
		data: {
			equip_no: no
		}
	});
	const new_date = format(res.data[0].transfer_date, 0);
	set(fd, 'equip_type_no', res.data[0].equip_type_no);
	const tt = fd.data.node.querySelector<HTMLInputElement>('[data-id="date"]');
	tt.value = new_date;
	const equip_internal_no = fd.data.node.querySelector<HTMLInputElement>('[data-id="equip_internal_no"]');
	equip_internal_no.value = res.data[0].equip_internal_no;
	const price = fd.data.node.querySelector<HTMLInputElement>('[data-id="transfer_price"]');
	price.value = res.data[0].transfer_price;
	const time = fd.data.node.querySelector<HTMLInputElement>('[data-id="transfer_time"]');
	time.value = res.data[0].transfer_time;
	const res1 = await nodejs<{ res: Array<{ equip_type_no: string }> }>('device-management-ygh/zj-000010/s007', {});
	const con = Object.assign({ res1 }, res.data[0]);
	const name = await nodejs<{ data: Array<{}> }>('device-management-ygh/zj-000010/s003', { equip_type_no: res.data[0].equip_type_no });
	render(fd, name.data[0], p002, 'p002', 'inner');
	render(fd, con, p001, 'p001', 'inner');
	const t1 = '固定资产类型';
	const title = await nodejs<Array<{ value_no: string }>>('device-management-ygh/zj-000010/s004', { value_title: t1 });
	const nn = title[0].value_no;
	const type = await nodejs<{ data: Array<{}> }>('device-management-ygh/zj-000010/s005', { value_no: nn });
	const conn1 = Object.assign({ type }, res.data[0]);
	render(fd, conn1, p003, 'p003', 'inner');
	const t2 = '设备状态';
	const stage = await nodejs<Array<{ value_no: string }>>('device-management-ygh/zj-000010/s004', { value_title: t2 });
	const sta = stage[0].value_no;
	const ss = await nodejs<{ data: Array<{}> }>('device-management-ygh/zj-000010/s005', { value_no: sta });
	const conn2 = Object.assign({ ss }, res.data[0]);
	render(fd, conn2, p004, 'p004', 'inner');
	const hide_s = await nodejs<Array<{ hidden_source: string }>>('device-management-ygh/zj-000010/s008', { equip_no: no });
	console.log('aaaaa111', hide_s);
	const q: string[] = [];
	for (let o = 0; o < hide_s.length; o++) {
		q[o] = hide_s[o].hidden_source;
	}
	console.log('ooooo', q);
	const atr = await nodejs<{ res: Array<{ hidden_source: string; hidden_name: string; assess_level: string }> }>('device-management-ygh/zj-000010/s009', { hidden_source: q });
	render(fd, atr.res[0], p006, 'p006', 'inner');
	set(fd, 'data', atr.res[0]);
	const tt1 = await nodejs<{ res: Array<{}> }>('device-management-ygh/zj-000010/s010', { equip_no: no });
	render(fd, tt1.res[0], p007, 'p007', 'inner');
	set(fd, 'data1', tt1.res[0]);
}
